package com.nc.solutions.rentacar.manager.Impl;

import com.nc.solutions.rentacar.domain.car.ICar;
import com.nc.solutions.rentacar.domain.car.Impl.Car;
import com.nc.solutions.rentacar.manager.ICarManager;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author Alex Avdeychik
 */
public class CarManager implements ICarManager {
    private Map<Integer, ICar> carMap;

    public CarManager() {
        carMap = new TreeMap<Integer, ICar>();
    }

    @Override
    public Map<Integer, ICar> getCarMap() {
        return new TreeMap(carMap);
    }

    @Override
    public void addCar(ICar car) {
        carMap.put((int)car.getID(), car);
    }

    @Override
    public boolean removeCar(int carId) {
        return carMap.remove(carId) != null;
    }

    @Override
    public ICar getCar(int carId) {
        return carMap.get(carId);
    }
   
}
